Class SimpleGraphIO

java.lang.Object
edu.claflin.finder.io.graph.SimpleGraphIO
All Implemented Interfaces:
GraphReader, GraphWriter

public final class SimpleGraphIO extends Object implements GraphReader, GraphWriter
A class for reading and writing graphs.
Version:
3.1.2 February 2, 2016
Author:
Charles Allen Schultz II
  • Constructor Details

    • SimpleGraphIO

      public SimpleGraphIO()
  • Method Details

    • parseGraph

      public Graph parseGraph(File source, boolean undirected)
      Reads a graph from memory. Reads simple tab delimited graphs. A graph file consists of an edge on each line with a tab delimiting the two nodes joined by the edge and followed by a floating point value representing the edge weight.
      Specified by:
      parseGraph in interface GraphReader
      Parameters:
      source - the File object representing the graph.
      undirected - a boolean indicating if the graph should be interpreted as undirected.
      Returns:
      the Graph object parsed from the file.
    • writeGraph

      public void writeGraph(Graph toWrite)
      Writes graphs to memory. Writes simple tab delimited graphs. Outputs to the disk a graph. Each line of the outputted graph represents an edge. The two nodes joined by the edge are delimited by a tab.
      Specified by:
      writeGraph in interface GraphWriter
      Parameters:
      toWrite - the Graph object to write to a file.
    • testFile

      private static boolean testFile(File file)
      Tests to see if a File is a valid graph file. Currently only tests by checking to ensure the provided file is not a directory.
      Parameters:
      file - the File to test.
      Returns:
      the boolean value representing if the file is valid.